import CodeMirror from 'codemirror'


/*
* 自定义CodeMirror模式，quesiotns模式
*/
CodeMirror.defineMode("questions", function(config, parserConfig) {
  return {
    startState() {
      return {}
    },
    token(stream, state) {
      if(state.isQuestionBegin) {
        state.isQuestionBegin = false
        stream.skipToEnd()
        return null
      }

      if(/^\d+[\.、][^\s]/.test(stream.string)) {
        stream.skipTo('.') || stream.skipTo('、')
        state.isQuestionBegin = true
        return 'question-seq'
      }

      stream.skipToEnd()
      return null
    },
  }
})